package gitee.derumin.lifeissohard.effects;

import gitee.derumin.lifeissohard.lishhungersystem.LishHungerManager;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectCategory;
import net.minecraft.server.network.ServerPlayerEntity;


public class Diarrhea extends StatusEffect {

    public Diarrhea(StatusEffectCategory category, int color) {
        super(category, color);
    }

    @Override
    public boolean canApplyUpdateEffect(int duration, int amplifier){
        return true;
    }

    @Override
    public void applyUpdateEffect(LivingEntity entity, int amplifier){
        if (entity instanceof ServerPlayerEntity serverPlayerEntity){
            if (serverPlayerEntity.getHungerManager() instanceof LishHungerManager lishHungerManager){
                lishHungerManager.diarrhea(amplifier);
            }
        }
    }

    @Override
    public Diarrhea addAttributeModifier(EntityAttribute attribute, String uuid, double amount, EntityAttributeModifier.Operation operation) {
        super.addAttributeModifier(attribute,uuid,amount,operation);
        return this;
    }
}
